﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Collections.ObjectModel; 

namespace InscriberControlClient
{
    /// <summary>
    /// Interaction logic for Window6.xaml
    /// </summary>
    public partial class Window6 : Window
    {
        public ObservableCollection<Anonsai> an;
        public int AnIx=1;
        public static bool isMove = false;

        public string kitasAnonsoIx(bool st)
        {
            string rez="";
            if (st)
            {
                AnIx++;
            }
            else
            {
                AnIx--;
            }
            rez = AnIx.ToString();
            return rez;
        }

        public Window6()
        {
            InitializeComponent();
            peopleListBox.DataContext = an;
        }
        private void Button_Click1(object sender, RoutedEventArgs e)
        {
            an = Functionality.getAnonsai("");
            peopleListBox.DataContext = an;
        }

        private void Button_Click2(object sender, RoutedEventArgs e)
        {
            this.Hide();
        }


         private void cmdkitas_Clicked(object sender, RoutedEventArgs e)
        {

            Button cmd = (Button)sender;
            if (cmd.DataContext is Anonsai)
            {

                Anonsai item = (Anonsai)cmd.DataContext;
                Functionality.kitasAN(item.nr.ToString(),kitasAnonsoIx(true));

            }

        }

         private void cmdatgal_Clicked(object sender, RoutedEventArgs e)
         {

             Button cmd = (Button)sender;
             if (cmd.DataContext is Anonsai)
             {

                 Anonsai item = (Anonsai)cmd.DataContext;
                 Functionality.kitasAN(item.nr.ToString(), kitasAnonsoIx(false));

             }

         }

        private void cmdRunLD_Clicked(object sender, RoutedEventArgs e)
        {

            Button cmd = (Button)sender;
            if (cmd.DataContext is Anonsai)
            {

                Anonsai item = (Anonsai)cmd.DataContext;
                Functionality.startAN(item.nr.ToString());

            }

        }

        private void cmdStopLD_Clicked(object sender, RoutedEventArgs e)
        {
            AnIx = 1;
            Button cmd = (Button)sender;
            if (cmd.DataContext is Anonsai)
            {

                Anonsai item = (Anonsai)cmd.DataContext;
                Functionality.stopAN();
            }

        }

        private void Window_MouseDown(object sender, MouseButtonEventArgs e)
        {
        }

        private void peopleListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            
        }

        private void peopleListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            Window7 w7 = new Window7();
            w7.Show();
        }

        private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
          /*  isMove = true;
            Functionality.lastPosition = Mouse.GetPosition(this);*/
        }

        private void peopleListBox_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
   
        }

        private void peopleListBox_MouseMove(object sender, MouseEventArgs e)
        {
      
        }

        private void Window_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            isMove = false;
        }

        private void Window_MouseMove(object sender, MouseEventArgs e)
        {
           /* if (isMove)
            {
                System.Windows.Point pt = Mouse.GetPosition(this);
                Functionality.DragMoveNew(this, e, pt);
            }*/
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

        }

        private void Window_MouseLeave(object sender, MouseEventArgs e)
        {
            isMove = false;
        }
    }
}
